package com.javaex.book.utils;

/**
 * 统一响应数据类型
 *
 * @author 黄星琦
 * @Date 2022年3月2日
 */
public class ReturnResult {

	private int code;
	private String message;
	private Object data;
	
	public ReturnResult() {
		this.code = Constants.Code.SUCCESS;
		this.message = Constants.Message.SUCCESS;
	}
	
	public ReturnResult(String message, Object data) {
		this.code = Constants.Code.SUCCESS;
		this.message = message;
		this.data = data;
	}

	public ReturnResult success() {
		this.code = Constants.Code.SUCCESS;
		return this;
	}
	
	public ReturnResult success(String message) {
		this.code = Constants.Code.SUCCESS;
		this.message = message;
		return this;
	}
	
	public ReturnResult success(String message, Object data) {
		this.code = Constants.Code.SUCCESS;
		this.message = message;
		this.data = data;
		return this;
	}
	
	public ReturnResult fail() {
		this.code = Constants.Code.FAIL;
		return this;
	}
	
	public ReturnResult fail(String message) {
		this.code = Constants.Code.FAIL;
		this.message = message;
		return this;
	}

	public int getCode() {
		return code;
	}

	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}

	public Object getData() {
		return data;
	}

	public void setData(Object data) {
		this.data = data;
	}
}
